#include <ros/ros.h>
#include "executor/chassis_executor.h"
#include "executor/gimbal_executor.h"
#include "behavior_tree/behavior_node.h"
#include "behavior_tree/behavior_tree.h"
#include "example_behavior/aim_behavior.h"
#include "example_behavior/back_boot_area_behavior.h"
#include "example_behavior/chase_behavior.h"
#include "example_behavior/circle_behavior.h"
#include "example_behavior/dance_behavior.h"
#include "example_behavior/escape_behavior.h"
#include "example_behavior/gimbal_aim_behavior.h"
#include "example_behavior/gimbalget0_behavior.h"
#include "example_behavior/goal_behavior.h"
#include "example_behavior/gogoal_behavior.h"
#include "example_behavior/patrol_behavior.h"
#include "example_behavior/search_behavior.h"
#include "example_behavior/shake_behavior.h"
#include "example_behavior/wait_behavior.h"
#include "example_behavior/bfs_search.h"
#include "example_behavior/buff_behavior.h"

void param_init(ros::NodeHandle& p){}

int main(int argc, char **argv){
    ros::init(argc, argv, "behavior_test_node");
	std::string full_path = ros::package::getPath("roborts_decision") + "/config/decision.prototxt";
	ros::NodeHandle nh_p("~") ;
	param_init(nh_p);
    auto blackboard_ptr_ = std::make_shared<roborts_decision::Blackboard>(full_path);
    roborts_decision::Blackboard* blackboard = &*blackboard_ptr_;
      auto bfs_search = new roborts_decision::BfsSearch(blackboard);//
    auto chassis_executor_ptr_ = std::make_shared<roborts_decision::ChassisExecutor>();
    chassis_executor_ptr_->Set_Search(bfs_search);//
    auto gimbal_executor_ptr_ = std::make_shared<roborts_decision::GimbalExecutor>();

    auto wait_action_= std::make_shared<roborts_decision::WaitAction>(blackboard_ptr_,chassis_executor_ptr_, gimbal_executor_ptr_);
    auto circle_action_ = std::make_shared<roborts_decision::CircleAction>(blackboard_ptr_,chassis_executor_ptr_);
    auto buff_action_=std::make_shared<roborts_decision::BuffAction>(blackboard_ptr_, chassis_executor_ptr_ );

    auto game_start_condition_=std::make_shared<roborts_decision::PreconditionNode>("game start condition", blackboard_ptr_, [&](){
        if(blackboard_ptr_->GetMyBulletSupplyBuffInfo())return true;
        else return false;
    }, roborts_decision::AbortType::BOTH);
    game_start_condition_->SetChild(buff_action_);

    auto root_selector_ = std::make_shared<roborts_decision::SelectorNode>("root",blackboard_ptr_);
    root_selector_->AddChildren(game_start_condition_);
    root_selector_->AddChildren(wait_action_);
    roborts_decision::BehaviorTree root(root_selector_,100);
    root.Run();
    return 0;
}